﻿namespace Hidistro.UI.SaleSystem.Tags
{
    using Hidistro.Core;
    using Hidistro.Entities;
    using Hidistro.SaleSystem.Catalog;
    using System;
    using System.Data;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class Js_Common_AllBrand : WebControl
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write(this.RendHtml());
        }

        public string RendHtml()
        {
            StringBuilder builder = new StringBuilder();

            int[] arr = new int[] { 1, 5, 3, 9, 13, 17, 20, 30 };
            builder.AppendFormat("<div class=\"longjong\">");
            for (int i = 0; i < arr.Length; i++)
            {
                DataTable brandCategories = CategoryBrowser.GetBrandCategories(arr[i], 50);
                if ((brandCategories != null) && (brandCategories.Rows.Count > 0))
                {
                    if (i < 1)
                    {
                        builder.AppendFormat("<div class=\"brandall\" style=\"display:block\">").AppendLine();
                    }
                    else
                    {
                        builder.AppendFormat("<div class=\"brandall\" style=\"display:none\">").AppendLine();
                    }
                    builder.AppendLine("<ul>");
                    foreach (DataRow row in brandCategories.Rows)
                    {
                        builder.AppendLine("<li>");
                        string a = Globals.GetSiteUrls().SubBrandDetails((int)row["BrandId"], row["RewriteName"]);
                        builder.AppendFormat("<a target=\"_blank\" href=\"{0}\"><img src=\"{1}\" width=\"{2}\"></a>", a, Globals.GetImgUrl(row["Logo"].ToString()), 150).AppendLine();
                        builder.AppendFormat("<p><a target=\"_blank\" href=\"{0}\">{1}</a></p>", a, row["BrandName"]).AppendLine();
                        builder.AppendLine("</li>");

                    }

                    builder.AppendLine("</ul>");
                    builder.AppendLine("</div>");
                }
            }
            builder.AppendFormat("</div>");
            return builder.ToString();
        }

        public int CommentId { get; set; }
    }
}

